import { useIntersectionObserver } from '@vueuse/core'
export default {
  install(app){
    // 1. 注册图片懒加载指令
    app.directive('img-lazy', {
      mounted(el, binding){
       const { stop } =  useIntersectionObserver( el,
          ([{ isIntersecting }]) => {
           // console.log(isIntersecting, '---====')
            if(isIntersecting){
              el.src = binding.value
              // 停止监听
              stop()
            }
          },)
      }
    })
    // 2. ...
  }
}